<?php 

class State
{
	static $gameState = array(
		'Initializing',
		'Running',
		'Ending',);

	static $stateTree = array(
		'Initializing' => array(
			'Watching',
			'PlaceArmy',
			),
		'Running' => array(
			'Watching',
			'PlaceArmy',
			'Attack',
			'Fortify',
			),
		'Ending' => array(),
		);
			

	function __construct($data = array())
	{
		$this->gameState 		= $data['gameState'];
		$this->playerState 		= $data['playerState'];
	}

	// factory function
	function getState()
	{
		/*
		*
		* should be changed to match backend settings
		*
		*/

		$state = array(
			gameState 		=> State::$gameState[0],
			//playerState		=> State::$stateTree[State::$gameState[0]][0],
		);

		return $state;

	}
}

$data = $_GET;

if ($data['action'] == 'execute')
{
	$state = State::getState();
	if ($data['json'] == 1)
		echo json_encode($state);
	else echo $state;
	
}
